package com.pyb.java.commonutil.eventbus;


import org.greenrobot.eventbus.EventBus;

/**
 * EventBus 工具类
 */

public class EventBusUtils {

    /**
     * 在需要接收消息的页面注册
     *
     * @param subscriber
     */
    public static void register(Object subscriber) {
        EventBus.getDefault().register(subscriber);
    }

    /**
     * 接收完之后解除注册
     *
     * @param subscriber
     */
    public static void unRegister(Object subscriber) {
        EventBus.getDefault().unregister(subscriber);
    }

    /**
     * 发送消息
     */
    public static void post(int what, Object msg) {
        EventBus.getDefault().post(new EventBusMessage(what, msg));
    }

    public static void post(int what){
        post(what, null);
    }

    public static EventBusBuild build(int what) {
        return new EventBusBuild(what);
    }

    static EventBus getEventBus() {
        return EventBus.getDefault();
    }

}
